package com.nageoffer.shortlink.common.config;

import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 布隆过滤器配置
 */
@Configuration
public class RBloomFilterConfiguration {
    @Bean
    public RBloomFilter<String> userRegisterCachePenetrationBloomFilter(RedissonClient redissonClient) {
        RBloomFilter<String> cachePenetrationBloomFilter = redissonClient.getBloomFilter("userRegisterCachePenetrationBloomFilter");
        cachePenetrationBloomFilter.tryInit(10000000,0.001);
        return cachePenetrationBloomFilter;
    }
    public RBloomFilter<String> shortUriCreateBloomFilter(RedissonClient redissonClient) {
        RBloomFilter<String> shortUriBloomFilter= redissonClient.getBloomFilter("shortUriBloomFilter");
        shortUriBloomFilter.tryInit(10000000,0.001);
        return shortUriBloomFilter;
    }
}